<!DOCTYPE html>
<html lang="zh" dir="ltr" class="client-nojs">
<head>
<title>wscanf, fwscanf, swscanf, wscanf_s, fwscanf_s, swscanf_s</title>
<meta charset="UTF-8">
<meta name="generator" content="MediaWiki 1.21.2">
<link rel="shortcut icon" href="../../../common/favicon.ico">
<link rel="stylesheet" href="../../../common/ext.css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" href="../../../common/site_modules.css">
<style>a:lang(ar),a:lang(ckb),a:lang(fa),a:lang(kk-arab),a:lang(mzn),a:lang(ps),a:lang(ur){text-decoration:none}#toc{display:none}.editsection{display:none}
/* cache key: mwiki1-mwiki_zh_:resourceloader:filter:minify-css:7:15cea3ec788a65b5187d4018eed543bf */</style>

<script src="../../../common/startup_scripts.js"></script>
<script>if(window.mw){
mw.config.set({"wgCanonicalNamespace":"","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":0,"wgPageName":"c/io/fwscanf","wgTitle":"c/io/fwscanf","wgCurRevisionId":50001,"wgArticleId":986,"wgIsArticle":true,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":["Todo no example"],"wgBreakFrames":false,"wgPageContentLanguage":"zh","wgSeparatorTransformTable":["",""],"wgDigitTransformTable":["",""],"wgDefaultDateFormat":"zh","wgMonthNames":["","1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],"wgMonthNamesShort":["","1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],"wgRelevantPageName":"c/io/fwscanf","wgUserVariant":"zh","wgRestrictionEdit":[],"wgRestrictionMove":[]});
}</script><script>if(window.mw){
mw.loader.implement("user.options",function(){mw.user.options.set({"ccmeonemails":0,"cols":80,"date":"default","diffonly":0,"disablemail":0,"disablesuggest":0,"editfont":"default","editondblclick":0,"editsection":0,"editsectiononrightclick":0,"enotifminoredits":0,"enotifrevealaddr":0,"enotifusertalkpages":1,"enotifwatchlistpages":0,"extendwatchlist":0,"externaldiff":0,"externaleditor":0,"fancysig":0,"forceeditsummary":0,"gender":"unknown","hideminor":0,"hidepatrolled":0,"imagesize":2,"justify":0,"math":1,"minordefault":0,"newpageshidepatrolled":0,"nocache":0,"noconvertlink":0,"norollbackdiff":0,"numberheadings":0,"previewonfirst":0,"previewontop":1,"quickbar":5,"rcdays":7,"rclimit":50,"rememberpassword":0,"rows":25,"searchlimit":20,"showhiddencats":0,"showjumplinks":1,"shownumberswatching":1,"showtoc":0,"showtoolbar":1,"skin":"cppreference2","stubthreshold":0,"thumbsize":2,"underline":2,"uselivepreview":0,"usenewrc":0,"watchcreations":0,"watchdefault":0,"watchdeletion":0,
"watchlistdays":3,"watchlisthideanons":0,"watchlisthidebots":0,"watchlisthideliu":0,"watchlisthideminor":0,"watchlisthideown":0,"watchlisthidepatrolled":0,"watchmoves":0,"wllimit":250,"variant":"zh","language":"zh","searchNs0":true,"searchNs1":false,"searchNs2":false,"searchNs3":false,"searchNs4":false,"searchNs5":false,"searchNs6":false,"searchNs7":false,"searchNs8":false,"searchNs9":false,"searchNs10":false,"searchNs11":false,"searchNs12":false,"searchNs13":false,"searchNs14":false,"searchNs15":false,"gadget-MathJax":1,"gadget-ColiruCompiler":1});;},{},{});mw.loader.implement("user.tokens",function(){mw.user.tokens.set({"editToken":"+\\","patrolToken":false,"watchToken":false});;},{},{});
/* cache key: mwiki1-mwiki_zh_:resourceloader:filter:minify-js:7:258d7cd6aa9aa67dee25e01fb6a9e505 */
}</script>
<script>if(window.mw){
mw.loader.load(["mediawiki.page.startup","mediawiki.legacy.wikibits","mediawiki.legacy.ajax"]);
}</script>
<style type="text/css">/*<![CDATA[*/
.source-c {line-height: normal;}
.source-c li, .source-c pre {
	line-height: normal; border: 0px none white;
}
/**
 * GeSHi Dynamically Generated Stylesheet
 * --------------------------------------
 * Dynamically generated stylesheet for c
 * CSS class: source-c, CSS id: 
 * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
 * (http://qbnz.com/highlighter/ and http://geshi.org/)
 * --------------------------------------
 */
.c.source-c .de1, .c.source-c .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}
.c.source-c  {font-family:monospace;}
.c.source-c .imp {font-weight: bold; color: red;}
.c.source-c li, .c.source-c .li1 {font-weight: normal; vertical-align:top;}
.c.source-c .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
.c.source-c .li2 {font-weight: bold; vertical-align:top;}
.c.source-c .kw1 {color: #0000dd;}
.c.source-c .kw2 {color: #0000ff;}
.c.source-c .kw3 {color: #0000dd;}
.c.source-c .kw4 {color: #0000ff;}
.c.source-c .co1 {color: #909090;}
.c.source-c .co2 {color: #339900;}
.c.source-c .coMULTI {color: #ff0000; font-style: italic;}
.c.source-c .es0 {color: #008000; font-weight: bold;}
.c.source-c .es1 {color: #008000; font-weight: bold;}
.c.source-c .es2 {color: #008000; font-weight: bold;}
.c.source-c .es3 {color: #008000; font-weight: bold;}
.c.source-c .es4 {color: #008000; font-weight: bold;}
.c.source-c .es5 {color: #008000; font-weight: bold;}
.c.source-c .br0 {color: #008000;}
.c.source-c .sy0 {color: #008000;}
.c.source-c .sy1 {color: #000080;}
.c.source-c .sy2 {color: #000040;}
.c.source-c .sy3 {color: #000040;}
.c.source-c .sy4 {color: #008080;}
.c.source-c .st0 {color: #008000;}
.c.source-c .nu0 {color: #000080;}
.c.source-c .nu6 {color:#000080;}
.c.source-c .nu8 {color:#000080;}
.c.source-c .nu12 {color:#000080;}
.c.source-c .nu16 {color:#000080;}
.c.source-c .nu17 {color:#000080;}
.c.source-c .nu18 {color:#000080;}
.c.source-c .nu19 {color:#000080;}
.c.source-c .ln-xtra, .c.source-c li.ln-xtra, .c.source-c div.ln-xtra {background-color: #ffc;}
.c.source-c span.xtra { display:block; }

/*]]>*/
</style><!--[if lt IE 7]><style type="text/css">body{behavior:url("/mwiki/skins/cppreference2/csshover.min.htc")}</style><![endif]--></head>
<body class="mediawiki ltr sitedir-ltr ns-0 ns-subject page-c_io_fwscanf skin-cppreference2 action-view cpp-navbar">
        <!-- header -->
        <!-- /header -->
        <!-- content -->
<div id="cpp-content-base">
            <div id="content">
                <a id="top"></a>
                <div id="mw-js-message" style="display:none;"></div>
                                <!-- firstHeading -->
<h1 id="firstHeading" class="firstHeading">wscanf, fwscanf, swscanf, wscanf_s, fwscanf_s, swscanf_s</h1>
                <!-- /firstHeading -->
                <!-- bodyContent -->
                <div id="bodyContent">
                                        <!-- tagline -->
                    <div id="siteSub">来自cppreference.com</div>
                    <!-- /tagline -->
                                        <!-- subtitle -->
                    <div id="contentSub"><span class="subpages">&lt; <a href="../../c.html" title="c">c</a>‎ | <a href="../io.html" title="c/io">io</a></span></div>
                    <!-- /subtitle -->
                                                            <!-- bodycontent -->
                    <div id="mw-content-text" lang="zh" dir="ltr" class="mw-content-ltr"><div class="t-navbar" style=""><div class="t-navbar-sep"> </div><div class="t-navbar-head"><a href="../../c.html" title="c"> C</a><div class="t-navbar-menu"><div><div><table class="t-nv-begin" cellpadding="0" style="line-height:1.1em;">
<tr class="t-nv"><td colspan="5"> <a href="../language.html" title="c/language">语言</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../header.html" title="c/header">头文件</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../types.html" title="c/types">类型支持</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../program.html" title="c/program">程序工具</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../variadic.html" title="c/variadic">变参数函数支持</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../memory.html" title="c/memory">动态内存管理</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../error.html" title="c/error">错误处理</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../chrono.html" title="c/chrono">日期和时间工具</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../string.html" title="c/string">字符串库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../algorithm.html" title="c/algorithm">算法</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../numeric.html" title="c/numeric">数值</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../io.html" title="c/io">输入/输出支持</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../locale.html" title="c/locale">本地化支持</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../thread.html" title="c/thread">线程支持</a> <span class="t-mark-rev t-since-c11">(C11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../atomic.html" title="c/atomic">原子操作</a> <span class="t-mark-rev t-since-c11">(C11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../experimental.html" title="c/experimental">技术规范</a> </td></tr>
</table></div><div></div></div></div></div><div class="t-navbar-sep"> </div><div class="t-navbar-head"><a href="../io.html" title="c/io"> 文件输入/输出</a><div class="t-navbar-menu"><div><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv-h1"><td colspan="5"> 函数</td></tr>
<tr class="t-nv-h2"><td colspan="5"> 文件访问</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="fopen.html" title="c/io/fopen"><span class="t-lines"><span>fopen</span><span>fopen_s</span></span></a></div><div><span class="t-lines"><span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="freopen.html" title="c/io/freopen"><span class="t-lines"><span>freopen</span><span>freopen_s</span></span></a></div><div><span class="t-lines"><span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="https://zh.cppreference.com/w/c/io/fwide" title="c/io/fwide"><span class="t-lines"><span>fwide</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-c95">(C95)</span></span></span></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="setbuf.html" title="c/io/setbuf"><span class="t-lines"><span>setbuf</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="setvbuf.html" title="c/io/setvbuf"><span class="t-lines"><span>setvbuf</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="fclose.html" title="c/io/fclose"><span class="t-lines"><span>fclose</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="fflush.html" title="c/io/fflush"><span class="t-lines"><span>fflush</span></span></a></div></div></td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 直接输入/输出</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="fread.html" title="c/io/fread"><span class="t-lines"><span>fread</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="fwrite.html" title="c/io/fwrite"><span class="t-lines"><span>fwrite</span></span></a></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 无格式输入/输出</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="fgetc.html" title="c/io/fgetc"><span class="t-lines"><span>fgetc</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="fgets.html" title="c/io/fgets"><span class="t-lines"><span>fgets</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="fputc.html" title="c/io/fputc"><span class="t-lines"><span>fputc</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="fputs.html" title="c/io/fputs"><span class="t-lines"><span>fputs</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="getchar.html" title="c/io/getchar"><span class="t-lines"><span>getchar</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="gets.html" title="c/io/gets"><span class="t-lines"><span>gets</span><span>gets_s</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-until-c11">(C11 前)</span></span><span><span class="t-mark-rev t-since-c11">(C11 起)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="putchar.html" title="c/io/putchar"><span class="t-lines"><span>putchar</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="puts.html" title="c/io/puts"><span class="t-lines"><span>puts</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ungetc.html" title="c/io/ungetc"><span class="t-lines"><span>ungetc</span></span></a></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="fgetwc.html" title="c/io/fgetwc"><span class="t-lines"><span>fgetwc</span><span>getwc</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-c95">(C95)</span></span><span><span class="t-mark-rev t-since-c95">(C95)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="fgetws.html" title="c/io/fgetws"><span class="t-lines"><span>fgetws</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-c95">(C95)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="fputwc.html" title="c/io/fputwc"><span class="t-lines"><span>fputwc</span><span>putwc</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-c95">(C95)</span></span><span><span class="t-mark-rev t-since-c95">(C95)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="fputws.html" title="c/io/fputws"><span class="t-lines"><span>fputws</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-c95">(C95)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="getwchar.html" title="c/io/getwchar"><span class="t-lines"><span>getwchar</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-c95">(C95)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="putwchar.html" title="c/io/putwchar"><span class="t-lines"><span>putwchar</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-c95">(C95)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ungetwc.html" title="c/io/ungetwc"><span class="t-lines"><span>ungetwc</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-c95">(C95)</span></span></span></div></div></td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 有格式输入</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="fscanf.html" title="c/io/fscanf"><span class="t-lines"><span>scanf</span><span>fscanf</span><span>sscanf</span><span>scanf_s</span><span>fscanf_s</span><span>sscanf_s</span></span></a></div><div><span class="t-lines"><span></span><span></span><span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><strong class="selflink"><span class="t-lines"><span>wscanf</span><span>fwscanf</span><span>swscanf</span><span>wscanf_s</span><span>fwscanf_s</span><span>swscanf_s</span></span></strong></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-c95">(C95)</span></span><span><span class="t-mark-rev t-since-c95">(C95)</span></span><span><span class="t-mark-rev t-since-c95">(C95)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span></span></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="vfscanf.html" title="c/io/vfscanf"><span class="t-lines"><span>vscanf</span><span>vfscanf</span><span>vsscanf</span><span>vscanf_s</span><span>vfscanf_s</span><span>vsscanf_s</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="vfwscanf.html" title="c/io/vfwscanf"><span class="t-lines"><span>vwscanf</span><span>vfwscanf</span><span>vswscanf</span><span>vwscanf_s</span><span>vfwscanf_s</span><span>vswscanf_s</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span></span></div></div></td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 有格式输出</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="fprintf.html" title="c/io/fprintf"><span class="t-lines"><span>printf</span><span>fprintf</span><span>sprintf</span><span>snprintf</span><span>printf_s</span><span>fprintf_s</span><span>sprintf_s</span><span>snprintf_s</span></span></a></div><div><span class="t-lines"><span></span><span></span><span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="fwprintf.html" title="c/io/fwprintf"><span class="t-lines"><span>wprintf</span><span>fwprintf</span><span>swprintf</span><span>wprintf_s</span><span>fwprintf_s</span><span>swprintf_s</span><span>snwprintf_s</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-c95">(C95)</span></span><span><span class="t-mark-rev t-since-c95">(C95)</span></span><span><span class="t-mark-rev t-since-c95">(C95)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span></span></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="vfprintf.html" title="c/io/vfprintf"><span class="t-lines"><span>vprintf</span><span>vfprintf</span><span>vsprintf</span><span>vsnprintf</span><span>vprintf_s</span><span>vfprintf_s</span><span>vsprintf_s</span><span>vsnprintf_s</span></span></a></div><div><span class="t-lines"><span></span><span></span><span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="vfwprintf.html" title="c/io/vfwprintf"><span class="t-lines"><span>vwprintf</span><span>vfwprintf</span><span>vswprintf</span><span>vwprintf_s</span><span>vfwprintf_s</span><span>vswprintf_s</span><span>vsnwprintf_s</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-c95">(C95)</span></span><span><span class="t-mark-rev t-since-c95">(C95)</span></span><span><span class="t-mark-rev t-since-c95">(C95)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span></span></div></div></td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 文件寻位</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ftell.html" title="c/io/ftell"><span class="t-lines"><span>ftell</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="fgetpos.html" title="c/io/fgetpos"><span class="t-lines"><span>fgetpos</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="fseek.html" title="c/io/fseek"><span class="t-lines"><span>fseek</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="fsetpos.html" title="c/io/fsetpos"><span class="t-lines"><span>fsetpos</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="rewind.html" title="c/io/rewind"><span class="t-lines"><span>rewind</span></span></a></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 错误处理</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="clearerr.html" title="c/io/clearerr"><span class="t-lines"><span>clearerr</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="feof.html" title="c/io/feof"><span class="t-lines"><span>feof</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ferror.html" title="c/io/ferror"><span class="t-lines"><span>ferror</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="perror.html" title="c/io/perror"><span class="t-lines"><span>perror</span></span></a></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 文件上的操作</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="remove.html" title="c/io/remove"><span class="t-lines"><span>remove</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="rename.html" title="c/io/rename"><span class="t-lines"><span>rename</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="tmpfile.html" title="c/io/tmpfile"><span class="t-lines"><span>tmpfile</span><span>tmpfile_s</span></span></a></div><div><span class="t-lines"><span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="tmpnam.html" title="c/io/tmpnam"><span class="t-lines"><span>tmpnam</span><span>tmpnam_s</span></span></a></div><div><span class="t-lines"><span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span></span></div></div></td></tr>
</table></div><div></div></div></div></div><div class="t-navbar-sep"> </div></div>
<table class="t-dcl-begin"><tbody>
<tr class="t-dsc-header">
<td> <div>定义于头文件 <code>&lt;wchar.h&gt;</code>
 </div></td>
<td></td>
<td></td>
</tr>
</tbody>
<tbody class="t-dcl-rev t-dcl-rev-num"><tr class="t-dcl-rev-aux">
<td></td>
<td rowspan="142">(1)</td>
<td></td>
</tr>
<tr class="t-dcl t-since-c95 t-until-c99">
<td> <div><span class="mw-geshi c source-c"><span class="kw4">int</span> wscanf<span class="br0">(</span> <span class="kw4">const</span> <span class="kw4">wchar_t</span> <span class="sy2">*</span>format, ... <span class="br0">)</span><span class="sy4">;</span></span></div></td>
<td class="t-dcl-nopad">  </td>
<td> <span class="t-mark-rev t-since-c95">(C95 起)</span> <br><span class="t-mark-rev t-until-c99">(C99 前)</span> </td>
</tr>
<tr class="t-dcl t-since-c99">
<td> <div><span class="mw-geshi c source-c"><span class="kw4">int</span> wscanf<span class="br0">(</span> <span class="kw4">const</span> <span class="kw4">wchar_t</span> <span class="sy2">*</span><span class="kw4">restrict</span> format, ... <span class="br0">)</span><span class="sy4">;</span></span></div></td>
<td class="t-dcl-nopad">  </td>
<td> <span class="t-mark-rev t-since-c99">(C99 起)</span> </td>
</tr>
</tbody><tbody>
</tbody>
<tbody class="t-dcl-rev t-dcl-rev-num"><tr class="t-dcl-rev-aux">
<td></td>
<td rowspan="142">(2)</td>
<td></td>
</tr>
<tr class="t-dcl t-since-c95 t-until-c99">
<td> <div><span class="mw-geshi c source-c"><span class="kw4">int</span> fwscanf<span class="br0">(</span> <a href="../io.html"><span class="kw881">FILE</span></a> <span class="sy2">*</span>stream, <span class="kw4">const</span> <span class="kw4">wchar_t</span> <span class="sy2">*</span>format, ... <span class="br0">)</span><span class="sy4">;</span></span></div></td>
<td class="t-dcl-nopad">  </td>
<td> <span class="t-mark-rev t-since-c95">(C95 起)</span> <br><span class="t-mark-rev t-until-c99">(C99 前)</span> </td>
</tr>
<tr class="t-dcl t-since-c99">
<td> <div><span class="mw-geshi c source-c"><span class="kw4">int</span> fwscanf<span class="br0">(</span> <a href="../io.html"><span class="kw881">FILE</span></a> <span class="sy2">*</span><span class="kw4">restrict</span> stream,<br>
             <span class="kw4">const</span> <span class="kw4">wchar_t</span> <span class="sy2">*</span><span class="kw4">restrict</span> format, ... <span class="br0">)</span><span class="sy4">;</span></span></div></td>
<td class="t-dcl-nopad">  </td>
<td> <span class="t-mark-rev t-since-c99">(C99 起)</span> </td>
</tr>
</tbody><tbody>
</tbody>
<tbody class="t-dcl-rev t-dcl-rev-num"><tr class="t-dcl-rev-aux">
<td></td>
<td rowspan="142">(3)</td>
<td></td>
</tr>
<tr class="t-dcl t-since-c95 t-until-c99">
<td> <div><span class="mw-geshi c source-c"><span class="kw4">int</span> swscanf<span class="br0">(</span> <span class="kw4">const</span> <span class="kw4">wchar_t</span> <span class="sy2">*</span>buffer, <span class="kw4">const</span> <span class="kw4">wchar_t</span> <span class="sy2">*</span>format, ... <span class="br0">)</span><span class="sy4">;</span></span></div></td>
<td class="t-dcl-nopad">  </td>
<td> <span class="t-mark-rev t-since-c95">(C95 起)</span> <br><span class="t-mark-rev t-until-c99">(C99 前)</span> </td>
</tr>
<tr class="t-dcl t-since-c99">
<td> <div><span class="mw-geshi c source-c"><span class="kw4">int</span> swscanf<span class="br0">(</span> <span class="kw4">const</span> <span class="kw4">wchar_t</span> <span class="sy2">*</span><span class="kw4">restrict</span> buffer,<br>
             <span class="kw4">const</span> <span class="kw4">wchar_t</span> <span class="sy2">*</span><span class="kw4">restrict</span> format, ... <span class="br0">)</span><span class="sy4">;</span></span></div></td>
<td class="t-dcl-nopad">  </td>
<td> <span class="t-mark-rev t-since-c99">(C99 起)</span> </td>
</tr>
</tbody><tbody>
<tr class="t-dcl t-since-c11">
<td> <div><span class="mw-geshi c source-c"><span class="kw4">int</span> wscanf_s<span class="br0">(</span> <span class="kw4">const</span> <span class="kw4">wchar_t</span> <span class="sy2">*</span><span class="kw4">restrict</span> format, ...<span class="br0">)</span><span class="sy4">;</span></span></div></td>
<td> (4) </td>
<td> <span class="t-mark-rev t-since-c11">(C11 起)</span> </td>
</tr>
<tr class="t-dcl t-since-c11">
<td> <div><span class="mw-geshi c source-c"><span class="kw4">int</span> fwscanf_s<span class="br0">(</span> <a href="../io.html"><span class="kw881">FILE</span></a> <span class="sy2">*</span><span class="kw4">restrict</span> stream,<br>
               <span class="kw4">const</span> <span class="kw4">wchar_t</span> <span class="sy2">*</span><span class="kw4">restrict</span> format, ...<span class="br0">)</span><span class="sy4">;</span></span></div></td>
<td> (5) </td>
<td> <span class="t-mark-rev t-since-c11">(C11 起)</span> </td>
</tr>
<tr class="t-dcl t-since-c11">
<td> <div><span class="mw-geshi c source-c"><span class="kw4">int</span> swscanf_s<span class="br0">(</span> <span class="kw4">const</span> <span class="kw4">wchar_t</span> <span class="sy2">*</span><span class="kw4">restrict</span> s,<br>
               <span class="kw4">const</span> <span class="kw4">wchar_t</span> <span class="sy2">*</span><span class="kw4">restrict</span> format, ...<span class="br0">)</span><span class="sy4">;</span></span></div></td>
<td> (6) </td>
<td> <span class="t-mark-rev t-since-c11">(C11 起)</span> </td>
</tr>
<tr class="t-dcl-sep"><td></td><td></td><td></td></tr>
</tbody></table>
<p>从各种资源读取数据，按照 <code>format</code> 转译，并存储结果于给定位置。
</p>
<div class="t-li1"><span class="t-li">1)</span> 从 <span class="t-lc"><a href="../io.html" title="c/io">stdin</a></span> 读取数据。</div>
<div class="t-li1"><span class="t-li">2)</span> 从文件流 <code>stream</code> 读取数据。</div>
<div class="t-li1"><span class="t-li">3)</span> 从空终止字符串 <code>buffer</code> 读取数据。抵达字符串结尾等价于 <code>fwscanf</code> 的抵达文件尾条件</div>
<div class="t-li1"><span class="t-li">4-6)</span> 同 <span class="t-v">(1-3)</span> ，除了 <span class="t-c"><span class="mw-geshi c source-c"><span class="sy2">%</span>c</span></span> 、 <span class="t-c"><span class="mw-geshi c source-c"><span class="sy2">%</span>s</span></span> 及 <span class="t-c"><span class="mw-geshi c source-c"><span class="sy2">%</span><span class="br0">[</span></span></span> 转换指定符要求二个参数（通常的指针和指示获取用数组大小的 <span class="t-lc">rsize_t</span> 类型值，以 %lc 读取单个宽字符时可以为 1 ），及在运行时检测下列错误，并调用当前安装的<a href="../error/set_constraint_handler_s.html" title="c/error/set constraint handler s">制约处理</a>函数：
<dl><dd><ul><li> 任何指针类型的参数为空指针
</li><li> <code>format</code> 、 <code>stream</code> 或 <code>buffer</code> 为空指针
</li><li> %c 、 %s 或 %[ 要写入的字符数加上空终止字符，会超出提供给这些转换指定符的第二个（ rsize_t ）参数
</li><li> 可选，任何其他可检测错误，例如未知转换指定符
</li></ul>
</dd><dd>
</dd><dd>同所有边界检查函数， <code>wscanf_s, fwscanf_s , swscanf_s</code> 仅若实现定义了 <span class="t-c"><span class="mw-geshi c source-c">__STDC_LIB_EXT1__</span></span> ，且用户在包含 <code>&lt;wchar.h&gt;</code> 前定义 <span class="t-c"><span class="mw-geshi c source-c">__STDC_WANT_LIB_EXT1__</span></span> 为整数常量 <span class="t-c"><span class="mw-geshi c source-c"><span class="nu0">1</span></span></span> 才保证可用。</dd></dl></div>

<h3><span class="mw-headline" id=".E5.8F.82.E6.95.B0">参数</span></h3>
<table class="t-par-begin">


<tr class="t-par">
<td>  stream
</td>
<td> -
</td>
<td> 要读取的输入文件流
</td></tr>
<tr class="t-par">
<td>  buffer
</td>
<td> -
</td>
<td> 指向要读取的空终止宽字符串的指针
</td></tr>
<tr class="t-par">
<td>  format
</td>
<td> -
</td>
<td> 指向指定读取输入方式的空终止宽字符串的指针。
<p>格式字符串由下列内容组成 
</p>
<ul><li> 非空白宽字符，除了 <code><b>%</b></code> ：每个格式字符串中的这种字符处理来自输入流的准确同一字符，或若它与流的下个字符比较不相等则导致函数失败。
</li><li> 空白符：任何格式字符串中的单个空白符处理所有来自输入的可用连续空白符（如同通过于循环中调用 <a href="../string/wide/iswspace.html" title="c/string/wide/iswspace"><tt>iswspace</tt></a> 确定）。注意格式字符串中 <span class="t-c"><span class="mw-geshi c source-c"><span class="st0">"<span class="es1">\n</span>"</span></span></span> 、 <span class="t-c"><span class="mw-geshi c source-c"><span class="st0">" "</span></span></span> 、 <span class="t-c"><span class="mw-geshi c source-c"><span class="st0">"<span class="es1">\t</span><span class="es1">\t</span>"</span></span></span> 或其他空白无区别。
</li><li> 转换指定：每个转换指定拥有下列格式：
</li></ul>
<dl><dd><ul><li> 引入用 <code><b>%</b></code> 字符
</li></ul>
</dd></dl>
<dl><dd><ul><li> <span class="t-mark">(可选)</span>赋值抑制字符 <code><b>*</b></code> 。若存在此选项，则此函数不将结果赋值给任何接收用参数。
</li></ul>
</dd></dl>
<dl><dd><ul><li> <span class="t-mark">(可选)</span>指定<i>最大域宽</i>的整数数字（大于零），即函数进行在当前转换指定所指定的转换时，允许处理的最大字符数。注意若不提供宽度，则 %s 和 %[ 可能导致缓冲区溢出。
</li></ul>
</dd></dl>
<dl><dd><ul><li> <span class="t-mark">(可选)</span>指定接收参数大小的<i>长度修饰符</i>，即实际目标类型。这影响转换准确性和溢出规则。默认目标类型对每个转换类型不同（见下表）。
</li></ul>
</dd></dl>
<dl><dd><ul><li> 转换格式指定符
</li></ul>
</dd></dl>
<p>下列格式指定符可用：
</p>
<table class="wikitable" style="text-align:center; font-size:85%; max-width:90em;">

<tr>
<th rowspan="1"> 转换<br>指定符
</th>
<th rowspan="1"> 解释
</th>
<th colspan="9"> 参数类型
</th></tr>
<tr>
<th colspan="2" style="text-align:right; font-weight:normal;"> 长度修饰符
</th>
<th> <code>hh</code>
<p><span class="t-mark-rev t-since-c99">(C99)</span>
</p>
</th>
<th> <code>h</code>
</th>
<th style="font-weight:normal;">（无）
</th>
<th> <code><b>l</b></code>
</th>
<th> <code><b>ll</b></code>
<p><span class="t-mark-rev t-since-c99">(C99)</span>
</p>
</th>
<th> <code><b>j</b></code>
<p><span class="t-mark-rev t-since-c99">(C99)</span>
</p>
</th>
<th> <code><b>z</b></code>
<p><span class="t-mark-rev t-since-c99">(C99)</span>
</p>
</th>
<th> <code><b>t</b></code>
<p><span class="t-mark-rev t-since-c99">(C99)</span>
</p>
</th>
<th> <code><b>L</b></code>
</th></tr>
<tr>
<th> <code>%</code>
</th>
<td style="text-align:left;"> 匹配字面 <code><b>%</b></code> 。
</td>
<td style="background: #ececec; color: grey; vertical-align: middle; text-align: center;" class="table-na"> <small>N/A</small>
</td>
<td style="background: #ececec; color: grey; vertical-align: middle; text-align: center;" class="table-na"> <small>N/A</small>
</td>
<td style="background: #ececec; color: grey; vertical-align: middle; text-align: center;" class="table-na"> <small>N/A</small>
</td>
<td style="background: #ececec; color: grey; vertical-align: middle; text-align: center;" class="table-na"> <small>N/A</small>
</td>
<td style="background: #ececec; color: grey; vertical-align: middle; text-align: center;" class="table-na"> <small>N/A</small>
</td>
<td style="background: #ececec; color: grey; vertical-align: middle; text-align: center;" class="table-na"> <small>N/A</small>
</td>
<td style="background: #ececec; color: grey; vertical-align: middle; text-align: center;" class="table-na"> <small>N/A</small>
</td>
<td style="background: #ececec; color: grey; vertical-align: middle; text-align: center;" class="table-na"> <small>N/A</small>
</td>
<td style="background: #ececec; color: grey; vertical-align: middle; text-align: center;" class="table-na"> <small>N/A</small>
</td></tr>
<tr>
<th> <code>c</code>
</th>
<td style="text-align:left;">
<dl><dd> 匹配一个<b>字符</b>或<b>字符</b>的序列
</dd></dl>
<p>若使用了宽度指定符，则匹配准确的<i>宽度</i>个宽字符（该参数必须是指向有充足空间的数组的指针）。不同于 %s 和 %[ ，它不会在数组后附加空字符。
</p>
</td>
<td rowspan="3" style="background: #ececec; color: grey; vertical-align: middle; text-align: center;" class="table-na"> <small>N/A</small>
</td>
<td rowspan="3" style="background: #ececec; color: grey; vertical-align: middle; text-align: center;" class="table-na"> <small>N/A</small>
</td>
<td rowspan="3"> <div class="t-vertical"><div><span class="t-c"><span class="mw-geshi c source-c"><span class="kw4">char</span><span class="sy2">*</span></span></span></div></div>
</td>
<td rowspan="3"> <div class="t-vertical"><div><span class="t-c"><span class="mw-geshi c source-c"><span class="kw4">wchar_t</span><span class="sy2">*</span></span></span></div></div>
</td>
<td rowspan="3" style="background: #ececec; color: grey; vertical-align: middle; text-align: center;" class="table-na"> <small>N/A</small>
</td>
<td rowspan="3" style="background: #ececec; color: grey; vertical-align: middle; text-align: center;" class="table-na"> <small>N/A</small>
</td>
<td rowspan="3" style="background: #ececec; color: grey; vertical-align: middle; text-align: center;" class="table-na"> <small>N/A</small>
</td>
<td rowspan="3" style="background: #ececec; color: grey; vertical-align: middle; text-align: center;" class="table-na"> <small>N/A</small>
</td>
<td rowspan="3" style="background: #ececec; color: grey; vertical-align: middle; text-align: center;" class="table-na"> <small>N/A</small>
</td></tr>
<tr>
<th> <code>s</code>
</th>
<td style="text-align:left;">
<dl><dd> 匹配非空白字符的序列（一个<b>字符串</b>）
</dd></dl>
<p>若使用宽度指定符，则至多匹配<i>宽度</i>个字符，或匹配到首个提前出现的空白符前。总是在匹配的字符后存储一个空字符（故参数数组必须有至少<i>宽度 +1 </i>个字符的空间）。
</p>
</td></tr>
<tr>
<th> <code>[</code><span class="t-spar">set</span><code>]</code>
</th>
<td style="text-align:left;">
<dl><dd>匹配一个来自 <span class="t-spar">set</span> 的字符的非空字符序列。
</dd></dl>
<p>若集合的首字符是 <code>^</code> ，则匹配所有不在集合中的字符。若集合以 <code>]</code> 或 <code>^]</code> 开始，则 <code>]</code> 字符亦被包含入集合。在扫描集合的非最初位置的字符 <code>-</code> 是否可以指示范围，如 <code>[0-9]</code> ，是实现定义的。若使用宽度指定符，则最多匹配到<i>宽度</i>。总是在匹配的字符后存储一个空字符（故参数数组必须有至少<i>宽度 +1 </i>个字符的空间）。
</p>
</td></tr>
<tr>
<th> <code>d</code>
</th>
<td style="text-align:left;">
<dl><dd>匹配一个<b>十进制整数</b>。
</dd></dl>
<p>该数的格式同 <a href="../string/wide/wcstol.html" title="c/string/wide/wcstol"><tt>wcstol()</tt></a> 以值 <span class="t-c"><span class="mw-geshi c source-c"><span class="nu0">10</span></span></span> 为 <code>base</code> 时所期望者
</p>
</td>
<td rowspan="6"> <div class="t-vertical"><div><span class="t-c"><span class="mw-geshi c source-c"><span class="kw4">signed</span> <span class="kw4">char</span><span class="sy2">*</span></span></span> 或 <span class="t-c"><span class="mw-geshi c source-c"><span class="kw4">unsigned</span> <span class="kw4">char</span><span class="sy2">*</span></span></span></div></div>
</td>
<td rowspan="6"> <div class="t-vertical"><div><span class="t-c"><span class="mw-geshi c source-c"><span class="kw4">signed</span> <span class="kw4">short</span><span class="sy2">*</span></span></span> 或 <span class="t-c"><span class="mw-geshi c source-c"><span class="kw4">unsigned</span> <span class="kw4">short</span><span class="sy2">*</span></span></span></div></div>
</td>
<td rowspan="6"> <div class="t-vertical"><div><span class="t-c"><span class="mw-geshi c source-c"><span class="kw4">signed</span> <span class="kw4">int</span><span class="sy2">*</span></span></span> 或 <span class="t-c"><span class="mw-geshi c source-c"><span class="kw4">unsigned</span> <span class="kw4">int</span><span class="sy2">*</span></span></span></div></div>
</td>
<td rowspan="6"> <div class="t-vertical"><div><span class="t-c"><span class="mw-geshi c source-c"><span class="kw4">signed</span> <span class="kw4">long</span><span class="sy2">*</span></span></span> 或 <span class="t-c"><span class="mw-geshi c source-c"><span class="kw4">unsigned</span> <span class="kw4">long</span><span class="sy2">*</span></span></span></div></div>
</td>
<td rowspan="6"> <div class="t-vertical"><div><span class="t-c"><span class="mw-geshi c source-c"><span class="kw4">signed</span> <span class="kw4">long</span> <span class="kw4">long</span><span class="sy2">*</span></span></span> 或 <span class="t-c"><span class="mw-geshi c source-c"><span class="kw4">unsigned</span> <span class="kw4">long</span> <span class="kw4">long</span><span class="sy2">*</span></span></span></div></div>
</td>
<td rowspan="6"> <div class="t-vertical"><div><span class="t-c"><span class="mw-geshi c source-c"><a href="../types/integer.html"><span class="kw118">intmax_t</span></a><span class="sy2">*</span></span></span> 或 <span class="t-c"><span class="mw-geshi c source-c"><a href="../types/integer.html"><span class="kw132">uintmax_t</span></a><span class="sy2">*</span></span></span></div></div>
</td>
<td rowspan="6"> <div class="t-vertical"><div><span class="t-c"><span class="mw-geshi c source-c"><a href="../types/size_t.html"><span class="kw100">size_t</span></a><span class="sy2">*</span></span></span></div></div>
</td>
<td rowspan="6"> <div class="t-vertical"><div><span class="t-c"><span class="mw-geshi c source-c"><a href="../types/ptrdiff_t.html"><span class="kw101">ptrdiff_t</span></a><span class="sy2">*</span></span></span></div></div>
</td>
<td rowspan="6" style="background: #ececec; color: grey; vertical-align: middle; text-align: center;" class="table-na"> <small>N/A</small>
</td></tr>
<tr>
<th> <code>i</code>
</th>
<td style="text-align:left;">
<dl><dd>匹配一个<b>整数</b>。
</dd></dl>
<p>该数的格式同 <a href="../string/wide/wcstol.html" title="c/string/wide/wcstol"><tt>wcstol()</tt></a> 以值 <span class="t-c"><span class="mw-geshi c source-c">​<span class="nu0">0</span>​</span></span> 为 <code>base</code> 时所期望者（基底以首个分析的字符确定）
</p>
</td></tr>
<tr>
<th> <code>u</code>
</th>
<td style="text-align:left;">
<dl><dd>匹配一个无符号<b>十进制整数</b>。 
</dd></dl>
<p>该数的格式同 <a href="../string/wide/wcstoul.html" title="c/string/wide/wcstoul"><tt>wcstoul()</tt></a> 以值 <span class="t-c"><span class="mw-geshi c source-c"><span class="nu0">10</span></span></span> 为 <code>base</code> 参数时所期望者。
</p>
</td></tr>
<tr>
<th> <code>o</code>
</th>
<td style="text-align:left;">
<dl><dd>匹配一个无符号<b>八进制数</b>。
</dd></dl>
<p>该数的格式同 <a href="../string/wide/wcstoul.html" title="c/string/wide/wcstoul"><tt>wcstoul()</tt></a> 以值 <span class="t-c"><span class="mw-geshi c source-c"><span class="nu0">8</span></span></span> 为 <code>base</code> 参数时所期望者。
</p>
</td></tr>
<tr>
<th> <code>x</code>, <code>X</code>
</th>
<td style="text-align:left;">
<dl><dd>匹配一个无符号<b>十六进制整数</b>。
</dd></dl>
<p>该数的格式同 <a href="../string/wide/wcstoul.html" title="c/string/wide/wcstoul"><tt>wcstoul()</tt></a> 以值 <span class="t-c"><span class="mw-geshi c source-c"><span class="nu0">16</span></span></span> 为 <code>base</code> 参数时所期望者。
</p>
</td></tr>
<tr>
<th> <code>n</code>
</th>
<td style="text-align:left;">
<dl><dd>返回<b>迄今读取的字符数</b>。
</dd></dl>
<p>不消耗输出。不增加赋值计数。若此指定符拥有赋值抑制运算符，则行为未定义。
</p>
</td></tr>
<tr>
<th> <code>a</code>, <code>A</code><span class="t-mark-rev t-since-c99">(C99)</span><br> <code>e</code>, <code>E</code><br> <code>f</code>, <code>F</code><br> <code>g</code>, <code>G</code>
</th>
<td style="text-align:left;">
<dl><dd>匹配一个<b>浮点数</b>。
</dd></dl>
<p>该数的格式同 <a href="../string/wide/wcstof.html" title="c/string/wide/wcstof"><tt>wcstof()</tt></a> 所期望者。
</p>
</td>
<td style="background: #ececec; color: grey; vertical-align: middle; text-align: center;" class="table-na"> <small>N/A</small>
</td>
<td style="background: #ececec; color: grey; vertical-align: middle; text-align: center;" class="table-na"> <small>N/A</small>
</td>
<td> <div class="t-vertical"><div><span class="t-c"><span class="mw-geshi c source-c"><span class="kw4">float</span><span class="sy2">*</span></span></span></div></div>
</td>
<td> <div class="t-vertical"><div><span class="t-c"><span class="mw-geshi c source-c"><span class="kw4">double</span><span class="sy2">*</span></span></span></div></div>
</td>
<td style="background: #ececec; color: grey; vertical-align: middle; text-align: center;" class="table-na"> <small>N/A</small>
</td>
<td style="background: #ececec; color: grey; vertical-align: middle; text-align: center;" class="table-na"> <small>N/A</small>
</td>
<td style="background: #ececec; color: grey; vertical-align: middle; text-align: center;" class="table-na"> <small>N/A</small>
</td>
<td style="background: #ececec; color: grey; vertical-align: middle; text-align: center;" class="table-na"> <small>N/A</small>
</td>
<td> <div class="t-vertical"><div><span class="t-c"><span class="mw-geshi c source-c"><span class="kw4">long</span> <span class="kw4">double</span><span class="sy2">*</span></span></span></div></div>
</td></tr>
<tr>
<th> <code>p</code>
</th>
<td style="text-align:left;">
<dl><dd>匹配定义一个<b>指针</b>的实现定义的字符序列。
</dd></dl>
<p><code>printf</code> 系列函数应该用 <code><b>%p</b></code> 格式指定符产生同样的序列。
</p>
</td>
<td style="background: #ececec; color: grey; vertical-align: middle; text-align: center;" class="table-na"> <small>N/A</small>
</td>
<td style="background: #ececec; color: grey; vertical-align: middle; text-align: center;" class="table-na"> <small>N/A</small>
</td>
<td> <div class="t-vertical"><div><span class="t-c"><span class="mw-geshi c source-c"><span class="kw4">void</span><span class="sy2">**</span></span></span></div></div>
</td>
<td style="background: #ececec; color: grey; vertical-align: middle; text-align: center;" class="table-na"> <small>N/A</small>
</td>
<td style="background: #ececec; color: grey; vertical-align: middle; text-align: center;" class="table-na"> <small>N/A</small>
</td>
<td style="background: #ececec; color: grey; vertical-align: middle; text-align: center;" class="table-na"> <small>N/A</small>
</td>
<td style="background: #ececec; color: grey; vertical-align: middle; text-align: center;" class="table-na"> <small>N/A</small>
</td>
<td style="background: #ececec; color: grey; vertical-align: middle; text-align: center;" class="table-na"> <small>N/A</small>
</td>
<td style="background: #ececec; color: grey; vertical-align: middle; text-align: center;" class="table-na"> <small>N/A</small>
</td></tr></table>
<p>对于每个异于 <code>n</code> 的转换指定符，不超过任何指定域宽，且要么是转换指定符所准确期待，要么是其所期待的前缀的最长输入字符序列，即是从流中消耗的内容。此消耗序列后的首个字符若存在，则保持未读取。若被消耗序列长度为零，或被消耗序列不能转换成上面所指定的项目，则发生匹配失败，除非遇到文件尾、编码错误，或阻止从流输入的读取错误，此情况下此为输入失败。
</p><p>所有异于 <code>[</code> 、 <code>c</code> 和 <code>n</code> 的转换指定符，在尝试分析输入前消耗并舍弃所有前导空白字符（如同以调用 <a href="../string/wide/iswspace.html" title="c/string/wide/iswspace"><tt>iswspace</tt></a> 来确定）。这些被消耗的字符不计入指定的最大域宽。
</p><p>若不使用长度指定符 <code>l</code> ，则转换指定符 <code>c</code> 、 <code>s</code> 和 <code>[</code> 进行宽到到多字节字符转换，如同在转换首字符前，通过用初始化到零的 <a href="../string/multibyte/mbstate_t.html" title="c/string/multibyte/mbstate t"><tt>mbstate_t</tt></a> 对象调用 <a href="../string/multibyte/wcrtomb.html" title="c/string/multibyte/wcrtomb"><tt>wcrtomb()</tt></a> 。
</p><p>转换指定符 <code>s</code> 与 <code>[</code> 始终在匹配字符之后存储一个空字符。目标数组的大小必须至少比指定域宽大一。
</p><p><a href="../types/integer.html" title="c/types/integer">定宽整数类型</a>（ <code>int8_t</code> 等）的正确的转换指定定义于头文件 <a href="../types/integer.html" title="c/types/integer">&lt;inttypes.h&gt;</a> （虽然 <a href="../types/integer.html" title="c/types/integer"><tt>SCNdMAX</tt></a> 、 <a href="../types/integer.html" title="c/types/integer"><tt>SCNuMAX</tt></a> 等就是 <code>%jd</code> 、 <code>%ju</code> 等的别名）。
</p><p>在每个转换指定符后有一个<a href="../language/eval_order.html" title="c/language/eval order">序列点</a>；这允许存储多个域到同一“池”变量中。
</p><p>在分析以无数字指数为结尾的不完整浮点值，如以转换指定符 <span class="t-c"><span class="mw-geshi c source-c"><span class="sy2">%</span>f</span></span> 分析 <span class="t-c"><span class="mw-geshi c source-c"><span class="st0">"100er"</span></span></span> 时，消耗序列 <span class="t-c"><span class="mw-geshi c source-c"><span class="st0">"100e"</span></span></span> （可能为合法浮点数的最长前缀），并导致匹配错误（被消耗序列不能转换成浮点数），而留下 <span class="t-c"><span class="mw-geshi c source-c"><span class="st0">"r"</span></span></span> 。某些既存实现不遵守此规则并回滚，通过消耗 <span class="t-c"><span class="mw-geshi c source-c"><span class="st0">"100"</span></span></span> 而留下 <span class="t-c"><span class="mw-geshi c source-c"><span class="st0">"er"</span></span></span> ，例如 <a rel="nofollow" class="external text" href="https://sourceware.org/bugzilla/show_bug.cgi?id=1765">glibc 漏洞 1765</a> 。
</p><p><br>
</p>
</td></tr>
<tr class="t-par">
<td>  ...
</td>
<td> -
</td>
<td>  接收参数
</td></tr></table>
<h3><span class="mw-headline" id=".E8.BF.94.E5.9B.9E.E5.80.BC">返回值</span></h3>
<div class="t-li1"><span class="t-li">1-3)</span> 成功赋值的接收参数数量，若在赋值首个接收参数前出现读取失败，则为 <span class="t-lc"><a href="../io.html" title="c/io">EOF</a></span> 。</div>
<div class="t-li1"><span class="t-li">4-6)</span> 同 <span class="t-v">(1-3)</span> ，除了若有运行时制约违规，则亦返回 <span class="t-lc"><a href="../io.html" title="c/io">EOF</a></span> 。</div>
<h3><span class="mw-headline" id=".E7.A4.BA.E4.BE.8B">示例</span></h3>
<table class="metadata plainlinks ambox mbox-small-left ambox-notice" style=""><tr><td class="mbox-empty-cell"></td><td class="mbox-text" style="">本节未完成<br>原因：暂无示例 </td></tr></table>
<h3><span class="mw-headline" id=".E5.BC.95.E7.94.A8">引用</span></h3>
<div class="t-ref-std-11">
<ul><li> C11 standard (ISO/IEC 9899:2011): 
</li></ul>
<dl><dd><ul><li> 7.29.2.2 The fwscanf function (p: 410-416)
</li></ul>
</dd></dl>
<dl><dd><ul><li> 7.29.2.4 The swscanf function (p: 417)
</li></ul>
</dd></dl>
<dl><dd><ul><li> 7.29.2.12 The wscanf function (p: 421)
</li></ul>
</dd></dl>
<dl><dd><ul><li> K.3.9.1.2 The fwscanf_s function (p: 628-629)
</li></ul>
</dd></dl>
<dl><dd><ul><li> K.3.9.1.5 The swscanf_s function (p: 631)
</li></ul>
</dd></dl>
<dl><dd><ul><li> K.3.9.1.14 The wscanf_s function (p: 638)
</li></ul>
</dd></dl>
<div class="t-ref-std-c99">
<ul><li> C99 standard (ISO/IEC 9899:1999): 
</li></ul>
<dl><dd><ul><li> 7.24.2.2 The fwscanf function (p: 356-362)
</li></ul>
</dd></dl>
<dl><dd><ul><li> 7.24.2.4 The swscanf function (p: 362)
</li></ul>
</dd></dl>
<dl><dd><ul><li> 7.24.2.12 The wscanf function (p: 366-367)
</li></ul>
</dd></dl>
</div>
<h3><span class="mw-headline" id=".E5.8F.82.E9.98.85">参阅</span></h3>
<table class="t-dsc-begin">

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="vfwscanf.html" title="c/io/vfwscanf"> <span class="t-lines"><span>vwscanf</span><span>vfwscanf</span><span>vswscanf</span><span>vwscanf_s</span><span>vfwscanf_s</span><span>vswscanf_s</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span></span></div></div>
</td>
<td>   从<span class="t-lc"><a href="../io.html" title="c/io">stdin</a></span>、文件流或缓冲区读取格式化宽字符输入<br>使用可变参数列表 <br> <span class="t-mark">(函数)</span> </td></tr>

</table></div>

<!-- 
NewPP limit report
Preprocessor visited node count: 8104/1000000
Preprocessor generated node count: 16023/1000000
Post‐expand include size: 206793/2097152 bytes
Template argument size: 50696/2097152 bytes
Highest expansion depth: 20/40
Expensive parser function count: 0/100
-->

<!-- Saved in parser cache with key mwiki1-mwiki_zh_:pcache:idhash:986-0!*!0!!zh!*!zh!* and timestamp 20200216201436 -->
</div>                    <!-- /bodycontent -->
                                        <!-- printfooter -->
                    <div class="printfooter">
                    来自“<a href="https://zh.cppreference.com/mwiki/index.php?title=c/io/fwscanf&amp;oldid=50001">https://zh.cppreference.com/mwiki/index.php?title=c/io/fwscanf&amp;oldid=50001</a>”                    </div>
                    <!-- /printfooter -->
                                                            <!-- catlinks -->
                    <!-- /catlinks -->
                                                            <div class="visualClear"></div>
                    <!-- debughtml -->
                                        <!-- /debughtml -->
                </div>
                <!-- /bodyContent -->
            </div>
        </div>
        <!-- /content -->
        <!-- footer -->
        <div id="cpp-footer-base" class="noprint">
            <div id="footer">
                        <div id="cpp-navigation">
            <h5>导航</h5>
            <ul><li><a href="https://zh.cppreference.com/w/c/io/fwscanf">Online version</a></li><li>Offline version retrieved 2020-03-14 18:00.</li></ul></div>
                        <ul id="footer-info">
                                    <li id="footer-info-lastmod"> 本页面最后修改于2017年10月26日 (星期四) 21:46。</li>
                                    <li id="footer-info-viewcount">此页面已被浏览过5,011次。</li>
                            </ul>
                    </div>
        </div>
        <!-- /footer -->
        <script>if(window.mw){
mw.loader.state({"site":"loading","user":"missing","user.groups":"ready"});
}</script>
<script src="../../../common/skin_scripts.js"></script>
<script>if(window.mw){
mw.loader.load(["mediawiki.action.view.postEdit","mediawiki.user","mediawiki.page.ready","mediawiki.searchSuggest","mediawiki.hidpi","ext.gadget.MathJax","ext.gadget.ColiruCompiler"], null, true);
}</script>
<script src="../../../common/site_scripts.js"></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-2828341-1']);
_gaq.push(['_setDomainName', 'cppreference.com']);
_gaq.push(['_trackPageview']);
</script><!-- Served in 3.769 secs. -->
	</body>
<!-- Cached 20200216201436 -->
</html>